<?php 
include('conexion.php');
$idFact=$_POST['idFact'];
$usuario->consulta('SELECT * FROM factura WHERE numero_factura='.$idFact.'');
$a = $usuario->extraer_registro();
$iva=$a['iva'];
$usuario2 = new Servidor_Base_Datos($servidor,"root",$pass,$base_datos);
$usuario3 = new Servidor_Base_Datos($servidor,"root",$pass,$base_datos);
$i=0;
$usuario->consulta('SELECT * FROM factura_detalle WHERE fk_factura='.$idFact.'');
if ($a=$usuario->extraer_registro()){
			echo'<h4>&nbsp;&nbsp;&nbsp;&nbsp;<strong>Factura </strong><span class="blue">Pendiente</span></h4>';
	$usuario2->consulta("SELECT c.nombre FROM cliente c, factura f WHERE f.numero_factura= ".$idFact."
																	 and f.fk_cliente = c.numero_cliente");
	$cli = $usuario2->extraer_registro();
	$usuario3->consulta("SELECT e.nombre, e.apellido FROM empleado e, factura f WHERE f.numero_factura=".$idFact."
																	 and f.fk_empleado = e.numero_empleado");
	$emp = $usuario3->extraer_registro();
	echo'<h4><strong>&nbsp;&nbsp;&nbsp;&nbsp;Codigo de Factura: </strong>'.$idFact.' | <strong>Cliente: </strong>'.$cli['nombre'].' <br></br> <strong>&nbsp;&nbsp;&nbsp;&nbsp;Empleado: </strong>'.$emp['nombre'].' '.$emp['apellido'].'</h4>';
	$usuario->consulta('SELECT * FROM factura_detalle WHERE fk_factura='.$idFact.'');
	echo'&nbsp;&nbsp;&nbsp;&nbsp;<div align="center"><table align="center" width="50%">
		<tr>
			<td align="Center">Codigo</td>
			<td align="Center">Producto</td>
			<td align="Center">Cantidad</td>
			<td align="Center">Precio</td>	
		</tr>';
	while($deta = $usuario->extraer_registro()){
		$i++;//#999999
		if ($i%2==1){
			echo'<tr bgcolor="#CCCCCC" align="center">';	
			}
		else{
			echo'<tr bgcolor="#CCCCCC" align="center">';
			}
			$numP=$deta['producto_numero_producto'];
			$usuario2->consulta("SELECT * FROM producto WHERE numero_producto='$numP'");
			$detalle = $usuario2->extraer_registro();
			echo'<td>'.$detalle['codigo'].'</td>
				 <td>'.$detalle['nombre'].'</td>
				 <td>'.$deta['cantidad'].'</td>
				 <td>'.$detalle['precio'].'</td></tr>';
				 $total = $detalle['precio']*$deta['cantidad']+$total;
		}
	echo'</table >';
						$iva = $iva/100;
						$ivaTotal = $total*$iva;
						$total = $total+$ivaTotal;
						$iva=$iva*100;
	//$iva = $total*0.12;
    //$total = $total+$iva;
	echo'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I.V.A('.$iva.'%): '.$ivaTotal.'<br></br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Total: '.$total.'<br></br>';
echo'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><a href="#" style="color:#006" align="right" onclick="retomarFactura('.$idFact.')">Retomar</a> | <a href="#" style="color:#006" align="right" onclick="eliminarFactura('.$idFact.')">Eliminar</a> | <a href="#" style="color:#006" align="right" onclick="ocultarInfo('.$idFact.')">Ocultar</a></strong></div>';
	}
	else{
		echo'<h4><strong>Disculpe la venta no tiene ningun producto</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><a href="#" style="color:#006" align="right" onclick="retomarFactura('.$idFact.')">Retomar</a> | <a href="#" style="color:#006" align="right" onclick="eliminarFactura('.$idFact.')">Eliminar</a> | <a href="#" style="color:#006" align="right" onclick="ocultarInfo('.$idFact.')">Ocultar</a></strong></div>';
		}
?>